<?php
session_start(); 
	include dirname(__FILE__)."/function.php";
	include dirname(dirname(dirname(__FILE__)))."/include/host-base.php";
		if(isset($_POST['submited'])&&$_POST['submited']==1) {
			$verify_code = addslashes(trim($_POST['verify-code']));
			if($verify_code!=$_SESSION['verify_code']) {
				echo '<script type="text/javascript">
							alert("验证码错误!");
							location.href="../index.php";
						</script>';
			}
			else {
			$username = $_POST['username'];
			$password = $_POST['password'];
			$username = addslashes($username);
			$password = addslashes($password);
			$password = md5($password);
			$student_id=addslashes($_POST['student_id']);
			$department=addslashes($_POST['department']);
			$grade=addslashes($_POST['grade']);
			$user_real_name=addslashes($_POST['user_real_name']);
			$sex=addslashes($_POST['sex']);
			$phone=addslashes($_POST['phone']);
			$params=array('username'=>'"'.$username.'"',
						  'password'=>'"'.$password.'"',
						  'student_id'=>'"'.$student_id.'"',
						  'sex'=>'"'.$sex.'"',
						   'grade'=>'"'.$grade.'"',
							'department'=>'"'.$department.'"',
							'user_real_name'=>'"'.$user_real_name.'"',
							'phone'=>'"'.$phone.'"'	
			);
			
			if (addSUser($params)) {
				$ret=getSUser($username, $password);
				if(mysql_num_rows($ret)>0) {
					$row = mysql_fetch_array($ret);
					$_SESSION['s_username']=$username;
					$_SESSION['s_user_id']=$row['id'];
					$_SESSION['s_user_role']=$row['user_role'];
				}
				alertInfo("注册成功", getHost().'/front-show/index.php');
		
			}
			else{
				alertInfo("注册失败", getHost().'/front-show/index.php');
			}
		}
	}
?>
	